package com.singleton.pattern.singleton.demo;

/**
 * @Classname LazyInnerClassSingleton
 * @Description 单例 静态内部类实现
 * @Date 2019/11/20 0020 17:03
 * @Created by 埔枘
 */
public class LazyInnerClassSingleton {

    private LazyInnerClassSingleton(){}

    public static LazyInnerClassSingleton lazySingleton = null;

    /**
     *  final 关键字 保证方法不会被 重写和重载
     * @return
     */
    public final static  LazyInnerClassSingleton getSingleton(){
        return LazyHolder.LAZY;
    }

    //默认不加载
    private static class LazyHolder {
        private static final LazyInnerClassSingleton LAZY = new LazyInnerClassSingleton();
    }
}
